<?php
namespace app\admin\validate\Order;
use think\validate;

class Order extends validate{

	/**
	 *@description 验证器规则
	 *@buildcode(true)
	*/
	protected $rule = [
		'order_num'=>['require','unique:order'],
		'order_type'=>['require'],
		'parent_id'=>['require'],
		'teacher_id'=>['require'],
		'class_fee'=>['require'],
		'class_num'=>['require','regex'=>'/^[0-9]*$/'],
		'class_hour'=>['require','regex'=>'/^[0-9]*$/'],
		'total_amount'=>['require','regex'=>'/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/'],
		'platform_amount'=>['regex'=>'/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/'],
		'coupon_fee'=>['regex'=>'/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/'],
		'actul_amount'=>['regex'=>'/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/'],
		'use_class_num'=>['regex'=>'/^[0-9]*$/'],
	];

	/**
	 *@description 错误提示
	 *@buildcode(true)
	*/
	protected $message = [
		'order_num.require'=>'订单编号不能为空',
		'order_num.unique'=>'订单编号已经存在',
		'order_type.require'=>'订单类型不能为空',
		'parent_id.require'=>'家长ID不能为空',
		'teacher_id.require'=>'老师ID不能为空',
		'class_fee.require'=>'课时单价不能为空',
		'class_num.require'=>'课时数量不能为空',
		'class_num.regex'=>'课时数量格式错误',
		'class_hour.require'=>'课时时长不能为空',
		'class_hour.regex'=>'课时时长格式错误',
		'total_amount.require'=>'课时总费用不能为空',
		'total_amount.regex'=>'课时总费用格式错误',
		'platform_amount.regex'=>'平台费用格式错误',
		'coupon_fee.regex'=>'优惠券费用格式错误',
		'actul_amount.regex'=>'实付费用格式错误',
		'use_class_num.regex'=>'已上课数量格式错误',
	];

	/**
	 *@description 验证场景
	 *@buildcode(true)
	*/
	protected $scene  = [
		'add'=>['order_num','order_type','parent_id','teacher_id','class_fee','class_num','class_hour'],
		'update'=>['order_num','order_type','parent_id','teacher_id','class_fee','class_num','class_hour'],
	];



}